package com.zhyl.demo.service.impl;

import com.zhyl.demo.entity.Health;
import com.zhyl.demo.mapper.HealthMapper;
import com.zhyl.demo.service.HealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * @author yang3
 */
@Service
public class HealthServiceImpl implements HealthService {
    private final HealthMapper healthMapper;
    @Autowired
    private HealthServiceImpl(HealthMapper healthMapper)
    {
        this.healthMapper = healthMapper;
    }

    @Override
    public Boolean insert(Health record) {
        int insert = healthMapper.insert(record);
        if (insert>=0){
            return true;
        }else {
            return false;
        }
    }





    @Override
    public Boolean deleteById(Integer id) {
        int i = healthMapper.deleteById(id);
        if (i>=0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public ArrayList<Health> selectByPatientId(Integer patientId) {
        ArrayList<Health> health = healthMapper.selectByPatientId(patientId);
        if (health!=null){
            return health;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<Health> selectAll() {
        ArrayList<Health> health = healthMapper.selectAll();
        if (health!=null){
            return health;
        }else {
            return  null;
        }
    }

    @Override
    public Health getHealthDetail(Integer healthId) {

        return healthMapper.getHealthDetail(healthId);
    }
}
